package com.newbye.operate
{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	
	public class SelectBorder extends Sprite
	{
		private static var borders:Vector.<SelectBorder> = new Vector.<SelectBorder>();
		
		public var targetDis:DisplayObject;
		
		public static function disposeBorder(boder:SelectBorder):void
		{
			if(null == boder)
			{
				return;
			}
			var index:int = borders.indexOf(boder);
			borders.splice(index, 1);
			if(null != boder.parent)
			{
				boder.parent.removeChild(boder);
			}
			boder.targetDis = null;
			boder = null;
		}
		
		public static function clearAllBorders():void
		{
			while(borders.length > 0)
			{
				disposeBorder(borders[0]);
			}
		}
		
		public static function disposeBorderByTarget(dis:DisplayObject):void
		{
			for each(var item:SelectBorder in borders)
			{
				if(item.targetDis == dis)
				{
					disposeBorder(item);
					break;
				}
			}
		}
		/**
		 *  
		 * @param w width
		 * @param h	height
		 * 
		 */		
		private var _shapeX:Number;
		private var _shapeY:Number;
		public function SelectBorder(w:Number, h:Number)
		{
			super();
			_shapeX = w;
			_shapeY = h;
			initShape();
			borders.push(this);
		}
		
		public function dispose():void
		{
			disposeBorder(this);
		}
		
		private function initShape():void
		{
			this.graphics.lineStyle(1, 0x000000, 0.7);
			this.graphics.drawRect(0, 0, _shapeX, _shapeY);
		}
		
	}
}